/**
 * @author wn
 * @date 2024/03/07 11:16:12
 * @description: 用户 API 接口
 */

import { request } from '@/utils/request'

const Url = {
	getUserInfo: '/auth/wxLogin', // 登录接口
	getCode: '/get/code', // 获取验证码
	getToken: '/user/authentication', // 验证码验证
}

/**
 * 获取用户信息
 * @param {*} code
 * @returns Promise
 */
export const getUserInfoApi = code =>
	request({
		url: Url.getUserInfo,
		data: { code },
	})

/**
 * 获取短信验证码
 * @param {*} tel 手机号
 * @returns Promise
 */
export const getVerificationCodeApi = tel =>
	request({
		method: 'POST',
		url: Url.getCode,
		data: { tel },
	})

/**
 * 验证验证码 获取 token
 * @param {*} tel 手机号
 * @param {*} code 短信验证码
 * @returns Promise
 */
export const getTokenApi = (tel, code) =>
	request({
		method: 'POST',
		url: Url.getToken,
		data: { tel, code },
	})
